// src/stores/index.js
import { createPinia } from 'pinia'
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'

const pinia = createPinia()

pinia.use(
    piniaPluginPersistedstate({
    storage: {
      getItem: (key) => localStorage.getItem(key),
      setItem: (key, value) => localStorage.setItem(key, value)
    },
    // 可以选择性开启持久化的 store
    filter: (store) => {
      return ['menu', 'user'].includes(store.$id)
    }
  })
)

export default pinia
